Skip to content

function to count extreme events#556

Merged
remicousin merged 3 commits intomasterfrom
extrev
Jan 30, 2026
Merged

function to count extreme events#556
remicousin merged 3 commits intomasterfrom
extrev

Conversation

@remicousin
Copy link
Contributor

I tried to think of a vectorial solution but couldn't. Probably because there is a "memory" aspect of the analysis: once a day is part of an extreme event, it can't be part of another one.

@remicousin remicousin self-assigned this Jul 17, 2025
Copy link
Collaborator

@aaron-kaplan aaron-kaplan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly a faster approach: keep the outer loop (window length), but replace the inner loop with a rolling sum. Instead of a single result array count, keep two: count and length. Then after calculating the rolling sum but before updating count, zero out new_event for windows that overlap a window that has already been counted.

@remicousin
Copy link
Contributor Author

Possibly a faster approach: keep the outer loop (window length), but replace the inner loop with a rolling sum. Instead of a single result array count, keep two: count and length. Then after calculating the rolling sum but before updating count, zero out new_event for windows that overlap a window that has already been counted.

I worked on this but as of now I don't see a way to do it all. I can see how not to count bigger windows that overlap with smaller windows previously identified via the window loop, but I don't see how to disqualify overlapping windows of same size. E.g. say you have 4 days with a, b, c, d values. All the size-w windows (ab, bc, cd) meet the criterion, bc is disqualified because b already contributing to ab, but that makes cd a valid count, but I can't know that before I tell bc is not valid. I don't see how to do that without some looping incrementation.

@remicousin
Copy link
Contributor Author

@aaron-kaplan , it doesn't seem possible to remove a reviewer so please so whatever you want to do here and in the future I won't include you if data ingestion or app set up is not involved.

@remicousin remicousin requested a review from xchourio January 19, 2026 11:12
@remicousin remicousin merged commit b7801db into master Jan 30, 2026
1 check passed
@remicousin remicousin deleted the extrev branch January 30, 2026 19:32
@xchourio
Copy link
Contributor

xchourio commented Feb 4, 2026

@remicousin This is the stress test I mentioned (the results). 1D means a single point with a time series of X days (1 year, 10 years, 30 years). 3D includes X and Y (a grid of approximately 27×60, which is more/less what the U.S. has at one-degree resolution). There are two tabs: one for 3-day windows and another for 8-day windows. The results in red correspond to your function. Please ignore the blue ones, because until I manage to make them perform the same associations as your function, they are not relevant.

note that I ran these tests on my laptop, which has the following specification:
CPU: 2 GHz Quad-Core Intel Core i5
Mem: 16GB 3733 MHz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments